package cn.wolfcode.shop.service.impl;

import cn.wolfcode.shop.domain.SkuPropertyValue;
import cn.wolfcode.shop.mapper.SkuPropertyValueMapper;
import cn.wolfcode.shop.service.ISkuPropertyValueService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

@Service
public class SkuPropertyValueServiceImpl implements ISkuPropertyValueService {

    @Autowired
    private SkuPropertyValueMapper skuPropertyValueMapper;

    @Override
    public List<SkuPropertyValue> queryByPropertyId(Long skuPropertyId) {
        return skuPropertyValueMapper.selectBySkuPropertyId(skuPropertyId);
    }

    @Override
    public void batchSaveOrUpdate(List<SkuPropertyValue> skuPropertyValueList) {
        for (SkuPropertyValue skuPropertyValue : skuPropertyValueList) {
            if (skuPropertyValue.getId() == null) {

                skuPropertyValueMapper.insert(skuPropertyValue);
            } else {
                skuPropertyValueMapper.updateByPrimaryKey(skuPropertyValue);
            }
        }
    }


    @Override
    public void deleteByPVId(Long skuPropertyValueId) {

        skuPropertyValueMapper.deleteByPrimaryKey(skuPropertyValueId);
    }

    @Override
    public List<SkuPropertyValue> queryBySkuPropertyId(Long skuPropertyId) {

        return skuPropertyValueMapper.selectBySkuPropertyId(skuPropertyId);
    }
}
